import request from "@/utils/request";
import {DeptForm, DeptQuery, DeptVO} from "./model";

class DeptAPI {
    /**
     * 部门树形表格
     *
     * @param queryParams
     */
    static getList(queryParams?: DeptQuery) {
        return request<any, ApiResult>({
            url: "/api/sysDept/listQuery",
            method: "post",
            data: queryParams,
        });
    }

    static getTree(queryParams?: DeptQuery) {
        return request<any, ApiResult>({
            url: "/api/sysDept/listTree",
            method: "post",
            data: queryParams,
        });
    }

    /**
     * 部门下拉列表
     */
    static getOptions() {
        return request<any, ApiResult>({
            url: "/api/sysDept/listTreeOption",
            method: "post",
        });
    }


    /**
     * 新增部门
     *
     * @param data
     */
    static add(data: DeptForm) {
        return request({
            url: "/api/sysDept/add",
            method: "post",
            data: data,
        });
    }

    /**
     *  修改部门
     *
     * @param id
     * @param data
     */
    static update(data: DeptForm) {
        return request({
            url: "/api/sysDept/update",
            method: "post",
            data: data,
        });
    }

    /**
     * 删除部门
     *
     * @param ids
     */
    static deleteByIds(ids: string) {
        return request({
            url: "/api/sysDept/delete",
            method: "post",
            data: {ids: ids}
        });
    }
}

export default DeptAPI;
